package conf

import (
	"gopkg.in/yaml.v3"
	"os"
)

type Config struct {
	Server Server `yaml:"server"`
	Mysql  Mysql  `yaml:"mysql"`
	Redis  Redis  `yaml:"redis"`
}

var Conf *Config

// LoadConf 读取配置文件
func LoadConf(path string) *Config {
	c := &Config{}
	data, err := os.ReadFile(path)
	if err != nil {
		panic(err)
	}
	err = yaml.Unmarshal(data, c)
	if err != nil {
		panic(err)
	}

	Conf = c
	return c
}
